package com.elvish.efast.common.exception;

import com.elvish.efast.common.entity.Result;
import com.elvish.efast.common.enums.ResultCode;
import com.elvish.efast.common.utils.ResultUtil;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 全局异常捕捉处理类
 *
 * @author elvish
 * @date 2018/11/16 16:29
 * @blog oschina(https : / / my.oschina.net / xiaozhutefannao)
 */
@RestController
@ControllerAdvice
public class ExceptionHandle {

    @ExceptionHandler(Exception.class)
    public Result defaultExceptionHandler(HttpServletRequest request, Exception e) throws Exception {
        return ResultUtil.fail(ResultCode.SERVER_ERROR);
    }


}
